<?php
class XString {
	/**
	 * @var string
	 */
	public $value;
	/**
	 * @var integer
	 */
	public $length;
	
	/**
	 * @param string $string
	 * @return XString
	 */
	function __construct( $string ){
		$this->value = '';
		$this->length = 0;
		
		if ( !is_string($string) )
			return $this;
			
		$this->value = $string;
		$this->length = strlen($string);
	}
	
	public function shiftAWord(){
		$words = preg_split('/[\W]/', $this->value, -1, 
			PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE) ;
			
		if ( 0 == count($words) ){
			return '';
		}
		
		$this->value = substr($this->value, $words[0][1] + strlen($words[0][0]));
		if ( false === $this->value ){
			$this->value = '';	
		}
		
		return $words[0][0];
	}
}